package com.joesem.sale.client.widget.dialog

import android.content.Context
import com.jiaxing.sale.client.databinding.DialogConfirmBinding
import com.joesem.sale.client.base.BaseDialog
import com.joesem.sale.client.utils.click


class ConfirmDialog(
    context: Context,
    val msg: String,
    val cancelText: String = "取消",
    val confirmText: String = "确定",
    val cancelClick: () -> Unit = {},
    val confirmClick: () -> Unit = {}
) : BaseDialog<DialogConfirmBinding>(context) {
    override fun DialogConfirmBinding.initView() {
        tvContent.text = msg
        btnCancel.text = cancelText
        btnConfirm.text = confirmText
        btnCancel.click {
            dismiss()
            cancelClick.invoke() }
        btnConfirm.click {
            dismiss()
            confirmClick.invoke() }
    }
}

fun optionConfirm(
    context: Context,
    msg: String,
    cancelText: String = "取消",
    confirmText: String = "确定",
    cancelClick: () -> Unit = {},
    confirmClick: () -> Unit = {}
) {
    ConfirmDialog(context, msg, cancelText, confirmText, cancelClick, confirmClick).show()
}